home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / lang / PPCSmllEiffel.lha / PPCSmallEiffel / lib_se / feature_clause.e < prev    next >
Text File  |  1998-01-16  |  4KB  |  177 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class FEATURE_CLAUSE
  17. --
  18. -- The contents of a feature clause.
  19. --
  20. -- Note : for a `pretty' pretty_printing, it is necessary to store exactly 
  21. --        the original contents (in the source file) of a feature   
  22. --        clause. 
  23. --   
  24.    
  25. inherit GLOBALS;
  26.  
  27. creation make
  28.    
  29. feature
  30.    
  31.    clients: CLIENT_LIST;
  32.      -- The clients allowed to use those features.
  33.    
  34.    comment: COMMENT;
  35.      -- The heading comment comming with the clause.
  36.    
  37. feature {NONE}
  38.    
  39.    list: FIXED_ARRAY[E_FEATURE]; 
  40.      -- Only the features of the current clause.
  41.      -- Note : all features of a class are grouped in a 
  42.      -- single DICTIONARY (see BASE_CLASS).
  43.    
  44. feature {ANY}
  45.    
  46.    make(c: like clients; cm: COMMENT; l: like list) is
  47.       require
  48.      c /= Void;
  49.      l /= Void implies l.empty;
  50.       do
  51.      clients := c;
  52.      comment := cm;
  53.      list := l;
  54.       ensure
  55.      clients = c;
  56.      comment = cm;
  57.      list = l;
  58.       end;
  59.    
  60.    pretty_print is
  61.       local
  62.      i: INTEGER;
  63.       do
  64.            fmt.set_indent_level(0);
  65.      if not fmt.zen_mode then
  66.         fmt.skip(1);
  67.      else
  68.         fmt.indent;
  69.      end;
  70.      fmt.keyword(fz_feature);
  71.      clients.pretty_print;
  72.      fmt.set_indent_level(0);
  73.      if comment /= Void then
  74.         if fmt.zen_mode then
  75.         elseif fmt.column > 15 then
  76.            fmt.set_indent_level(1);
  77.            fmt.indent;
  78.            fmt.set_indent_level(0);
  79.         end;
  80.         comment.pretty_print;
  81.         if not fmt.zen_mode then
  82.            fmt.skip(1);
  83.         end;
  84.      end;
  85.      if list /= Void then
  86.         from  
  87.            i := 0;
  88.         until
  89.            i > list.upper
  90.         loop
  91.            fmt.set_indent_level(1);
  92.            fmt.indent;
  93.            if not fmt.zen_mode then
  94.           fmt.skip(1);
  95.            end;
  96.            list.item(i).pretty_print;
  97.            i := i + 1;
  98.         end;
  99.      end;
  100.            fmt.set_indent_level(0);
  101.      if not fmt.zen_mode then
  102.         fmt.skip(1);
  103.      end;
  104.       end;
  105.  
  106. feature {FEATURE_CLAUSE_LIST}
  107.  
  108.    for_short(bcn: CLASS_NAME; sort: BOOLEAN; 
  109.          rf_list: FIXED_ARRAY[RUN_FEATURE]; rc: RUN_CLASS) is
  110.       local
  111.      i: INTEGER;
  112.      f: E_FEATURE;
  113.      heading_done: BOOLEAN;
  114.       do
  115.      if list /= Void and then
  116.         clients.gives_permission_to_any
  117.       then
  118.         from  
  119.            i := 0;
  120.         until
  121.            i > list.upper
  122.         loop
  123.            f := list.item(i);
  124.            heading_done := f.names.for_short(Current,heading_done,
  125.                          bcn,sort,rf_list,rc);
  126.            i := i + 1;
  127.         end;
  128.      end;
  129.       end;
  130.  
  131. feature {FEATURE_NAME_LIST}
  132.  
  133.    do_heading_for_short(bcn: CLASS_NAME) is
  134.       do
  135.      if comment = Void then
  136.         short_print.hook_or("hook202","feature(s) from ");
  137.         short_print.a_class_name(bcn);
  138.         short_print.hook_or("hook203","%N");
  139.      else
  140.         short_print.hook_or("hook204","feature(s) from ");
  141.         short_print.a_class_name(bcn);
  142.         short_print.hook_or("hook205","%N");
  143.         comment.short("hook206","   -- ","hook207","%N");
  144.         short_print.hook_or("hook208","");
  145.      end;
  146.       end;
  147.    
  148. feature {FEATURE_CLAUSE_LIST}
  149.    
  150.    add_into(fd: DICTIONARY[E_FEATURE,STRING]) is
  151.       local
  152.      i: INTEGER;
  153.      f: E_FEATURE;
  154.       do
  155.      if list /= Void then
  156.         from  
  157.            i := 0;
  158.         until
  159.            i > list.upper
  160.         loop
  161.            f := list.item(i);
  162.            f.set_clients(clients);
  163.            f.add_into(fd);
  164.            i := i + 1;
  165.         end;
  166.      end;
  167.       end;
  168.    
  169. invariant
  170.    
  171.    clients /= Void;
  172.    
  173.    list /= Void implies not list.empty;
  174.    
  175. end -- FEATURE_CLAUSE
  176.  
  177.